package com.yong.android.framework.dialog;

import android.content.Context;
import android.view.View;

import com.yong.android.framework.R;

/**
 * Created by Yong.
 * E-mail：775811790@qq.com
 * 2017/11/30
 * 子类：customDialog
 */


public class BaseDialog {

    private Context context;
    private CustomDialog dialog;
    public BaseDialog(Context context){
        this.context=context;
    }
    /**
     * @param content         内容
     * @param confirm         按钮文字
     * @param confirmListener 按钮监听
     *                        只有一个确定键
     */
    public void showOneButtonDialog(String content, String confirm, View.OnClickListener confirmListener) {
        dialog = new CustomDialog.Builder(context)
                .setTheme(R.style.ReportDialogStyle)
                .setContent(content)
                .cancelTouchOutside(true)
                .setHeightDp(120)
                .setWidthDp(240)
                .addConfirmClickListener(confirm, confirmListener)
                .showOneButton()
                .build();
        dialog.show();
    }

    /**
     * @param content         内容
     * @param confirm         按钮文字
     * @param confirmListener 按钮监听
     *                        确定取消
     */
    public void showConfirmCancelButtonDialog(String content, String confirm, View.OnClickListener confirmListener ,View.OnClickListener cancelListener) {
        dialog = new CustomDialog.Builder(context)
                .setTheme(R.style.ReportDialogStyle)
                .setContent(content)
                .cancelTouchOutside(true)
                .setHeightDp(120)
                .setWidthDp(240)
                .addConfirmClickListener(confirm, confirmListener)
                .addCancelClickListener("取消", cancelListener)
                .build();
        dialog.show();
    }



    /**
     * 隐藏dialog
     */
    public void dismissDialog() {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
    }
}
